#include <iostream>
#include <vector>
#include <set>
using namespace std;

const int maxn = 1e4+5;
int n,m,k,a[maxn];
vector<int> g[maxn];

signed main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cin>>k;
    for(int i=0;i<k;i++){
        int flag = 1;
        set<int> s;
        for(int j=0;j<n;j++){
            cin>>a[j];
            s.insert(a[j]);
        }
        for(int j=0;j<n;j++){
            for(int p=0;p<g[j].size();p++){
                if(a[j]==a[g[j][p]])    flag = 0;
            }
        }
        if(flag)    cout<<s.size()<<"-coloring\n";
        else    cout<<"No\n";
    }
    return 0;
}
